package com.wty.swhn.wty.biz.implAsmackImpl;

import com.wty.swhn.wty.TApplication;

import org.jivesoftware.smack.packet.Message;


/**
 * Created by swhn on 2016/8/7.
 */
public class SendNullPackage extends Thread {
    private  static SendNullPackage intance;

    public SendNullPackage() {
        this.start();
    }

    public synchronized static SendNullPackage  newInstance(){
        if (intance==null){
            intance=new SendNullPackage();
        }
        return intance;
    }


    boolean isRun=true;
    @Override
    public void run() {

        super.run();
        while (isRun){
            try {
                this.sleep(4*60*1000);//睡眠4分钟
                Message message=new Message();
                message.setFrom(TApplication.currentUser);// 设置连接服务器的主机，端口号
                message.setTo("pc1@tarean.com");
                // 服务器上要知道这个用户在不在线
                message.setBody("username online");
                message.setType(Message.Type.chat);

                TApplication.xmppConnection.sendPacket(message);
            }catch (Exception e){
                e.printStackTrace();
            }
        }
    }
}

